﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Theme_3_UserControls_PicNews : System.Web.UI.UserControl
{
    PowerCreator.LMS.Web.CMS.New opNews = new PowerCreator.LMS.Web.CMS.New();
    protected string Html="";
    protected void Page_Load(object sender, EventArgs e)
    {
        Html=BinderNews();
    }
    private string BinderNews()
    {
        string sHtml="";
        string sPic="<ul id=\"idSlider\" class=\"focus_pic\">";
        string sNum="<ul class=\"slider_num\" id=\"idNum\">";
        string search = " NewState = 1 and  NewPictureUrl is not null";
        string orderBy = " NewPublishTime desc ";
        DataTable dt = opNews.Query(search, orderBy, 5, 1);
        for(int i=0;i<dt.Rows.Count;i++)
        {
            sPic += "<li><a href=\"javascript:window.location('OpenNews.aspx?NewsID=" + dt.Rows[i]["NewID"].ToString() + "')\" target=\"_blank\"><img alt=\"\" src=\"" + dt.Rows[i]["NewPictureUrl"].ToString() + "\" ><strong></strong><em>" + PowerCreator.LMS.Common.Utils.StringUtils.GetSubstringLue(dt.Rows[i]["NewTitle"].ToString(), 42) + "</em></a></li>";
            sNum += "<li><a href=\"OpenNews.aspx?NewsID=" + dt.Rows[i]["NewID"].ToString() + "\" target=\"_blank\">" + (i + 1) + "</a></li>";
        }
        sPic += "</ul>";
        sNum += "</ul>";
        sHtml = sPic + sNum;
        return sHtml;
    }

}
